Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement simulation-scoped log levels #152

Merged
merged 4 commits into from Jun 9, 2018
Merged

Implement simulation-scoped log levels #152

merged 4 commits into from Jun 9, 2018

Conversation

Enchufa2
Copy link
Member

@Enchufa2 Enchufa2 commented Jun 5, 2018

@mtbakerguy: I've given a better thought to your proposal in #150:

Similar to the syslog interface, add an optional modifier to log_ to allow for levels of debugging.

I'll merge #151 anyway because it was an easy change and it seems that it doesn't break anything, but implementing debugging levels on top of it has one major drawback: rollbacks (if present) break when the logging level causes the log_() activity to be dropped from the trajectory.

Therefore, this PR implements simulation-scoped log levels while avoiding this issue:

library(simmer)

t <- trajectory() %>%
  log_("Message 0") %>%
  log_("Message 1", level=1) %>%
  log_("Message 2", level=2) %>%
  rollback(1, 1)

simmer() %>%
  add_generator("dummy", t, at(0)) %>%
  run() %>% invisible
#> 0: dummy0: Message 0

simmer(log_level=1) %>%
  add_generator("dummy", t, at(0)) %>%
  run() %>% invisible
#> 0: dummy0: Message 0
#> 0: dummy0: Message 1

simmer(log_level=Inf) %>%
  add_generator("dummy", t, at(0)) %>%
  run() %>% invisible
#> 0: dummy0: Message 0
#> 0: dummy0: Message 1
#> 0: dummy0: Message 2
#> 0: dummy0: Message 2

Feedback welcome.

@codecov
Copy link

codecov bot commented Jun 5, 2018

Codecov Report

Merging #152 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #152   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          52     52           
  Lines        2824   2827    +3     
=====================================
+ Hits         2824   2827    +3
Impacted Files Coverage Δ
inst/include/simmer/activity/log.h 100% <100%> (ø) ⬆️
R/trajectory-class.R 100% <100%> (ø) ⬆️
src/simulator.cpp 100% <100%> (ø) ⬆️
R/simmer-methods.R 100% <100%> (ø) ⬆️
R/simmer-class.R 100% <100%> (ø) ⬆️
src/activity.cpp 100% <100%> (ø) ⬆️
inst/include/simmer/simulator.h 100% <100%> (ø) ⬆️
R/trajectory-activities.R 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9cf8c7e...480818f. Read the comment docs.

@Enchufa2 Enchufa2 merged commit 0b9d7ae into master Jun 9, 2018
@Enchufa2 Enchufa2 deleted the log-level branch June 9, 2018 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant